package com.singleton.sample{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	[ExcludeClass]

	
	public class SampleSingletonImpl extends EventDispatcher implements ISingletonSample{
	//	include "../core/Version.as";
		
		// required generic functions
		public function SampleSingletonImpl(){
			super()
			this.init()
		}
		private static var instance:ISingletonSample;
		public static function getInstance():ISingletonSample{
			if (!instance)
				instance = new SampleSingletonImpl()
			return instance;
		}
		
		
		
		// start of custom functions and vars
		private var cnt:int
		private var timer:Timer
		private function init( ):void{
			this.cnt = 0;
			this.timer = new Timer( 1000 )
			this.timer.addEventListener(TimerEvent.TIMER, tick )
			this.timer.start()
		}
		public function tick( e:Event ):void{
			this.cnt++
			this.dispatchEvent( new SampleSingletonEvent( SampleSingletonEvent.TICK ) )
		}
		public function myAddEventListener( type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false ):void{
			this.addEventListener( type, listener, useCapture, priority, useWeakReference )
		}
		
		public function get tickCount():int{
			return this.cnt;
		}

	}
}